﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Platform.Migrations
{
    /// <inheritdoc />
    public partial class modify_openapifuncConfig : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MainDataTableDict_MainOpenApiConfig_OpenApiDictId",
                table: "MainDataTableDict");

            migrationBuilder.DropForeignKey(
                name: "FK_MainDataViewContainerDict_MainOpenApiConfig_OpenApiDictId",
                table: "MainDataViewContainerDict");

            migrationBuilder.DropTable(
                name: "MainOpenApiConfig");

            migrationBuilder.DropIndex(
                name: "IX_MainDataViewContainerDict_OpenApiDictId",
                table: "MainDataViewContainerDict");

            migrationBuilder.DropIndex(
                name: "IX_MainDataTableDict_OpenApiDictId",
                table: "MainDataTableDict");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "MainOpenApiConfig",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    ApiDictName = table.Column<string>(type: "text", nullable: false),
                    ApiSchema = table.Column<string>(type: "text", nullable: true),
                    AppTopicId = table.Column<Guid>(type: "uuid", nullable: true),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    DeleterId = table.Column<Guid>(type: "uuid", nullable: true),
                    DeletionTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    InfNo = table.Column<string>(type: "text", nullable: false),
                    InfVerno = table.Column<int>(type: "integer", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    OpenApiSats = table.Column<int>(type: "integer", nullable: false),
                    SignType = table.Column<string>(type: "text", nullable: true),
                    SrtNo = table.Column<int>(type: "integer", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainOpenApiConfig", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainOpenApiConfig_MainAppTopic_AppTopicId",
                        column: x => x.AppTopicId,
                        principalTable: "MainAppTopic",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateIndex(
                name: "IX_MainDataViewContainerDict_OpenApiDictId",
                table: "MainDataViewContainerDict",
                column: "OpenApiDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainDataTableDict_OpenApiDictId",
                table: "MainDataTableDict",
                column: "OpenApiDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainOpenApiConfig_AppTopicId",
                table: "MainOpenApiConfig",
                column: "AppTopicId");

            migrationBuilder.AddForeignKey(
                name: "FK_MainDataTableDict_MainOpenApiConfig_OpenApiDictId",
                table: "MainDataTableDict",
                column: "OpenApiDictId",
                principalTable: "MainOpenApiConfig",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_MainDataViewContainerDict_MainOpenApiConfig_OpenApiDictId",
                table: "MainDataViewContainerDict",
                column: "OpenApiDictId",
                principalTable: "MainOpenApiConfig",
                principalColumn: "Id");
        }
    }
}
